using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;

namespace zapLoader {
	public partial class AboutForm : Form {
		public AboutForm() {
			InitializeComponent();

			this.lblTitle.Text = this.AssemblyTitle + " " + String.Format("{0}", this.AssemblyVersion);
			this.lblCopyright.Text = this.AssemblyCopyright.Substring(0, 27);
			this.lblCopyright2.Text = this.AssemblyCopyright.Substring(28);
			this.lblDesc1.Text = this.AssemblyDescription.Substring(0, 27);
			this.lblDesc2.Text = this.AssemblyDescription.Substring(27, 27);
			this.lblDesc3.Text = this.AssemblyDescription.Substring(55);
		}

		private void AboutForm_Click(object sender, EventArgs e) {
			this.Close();
		}

		private void pbBack_Click(object sender, EventArgs e) {
			this.Close();
		}

		private void pbLogo_Click(object sender, EventArgs e) {
			this.Close();
		}

		private void lblTitle_Click(object sender, EventArgs e) {
			this.Close();
		}

		private void lblCopyright_Click(object sender, EventArgs e) {
			this.Close();
		}

		private void lblDesc1_Click(object sender, EventArgs e) {
			this.Close();
		}

		private void lblDesc2_Click(object sender, EventArgs e) {
			this.Close();
		}

		private void lblDesc3_Click(object sender, EventArgs e) {
			this.Close();
		}

		// -----------------------------------------
		// PROPERTIES
		// -----------------------------------------

		/// <summary>
		/// Get the Assembly version
		/// </summary>
		public string AssemblyVersion {
			get { return Assembly.GetExecutingAssembly().GetName().Version.ToString(); }
		}

		/// <summary>
		/// Get the Assembly title
		/// </summary>
		public string AssemblyTitle {
			get {
				object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
				
				if(attributes.Length > 0) {
					AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
					
					if(titleAttribute.Title != "")
						return titleAttribute.Title;
				}
				
				return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
			}
		}

		/// <summary>
		/// Get the Assembly description
		/// </summary>
		public string AssemblyDescription {
			get {
				object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);

				if(attributes.Length == 0)
					return "";

				return ((AssemblyDescriptionAttribute)attributes[0]).Description;
			}
		}

		/// <summary>
		/// Get the assembly copyright
		/// </summary>
		public string AssemblyCopyright {
			get {

				object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);

				if(attributes.Length == 0)
					return "";

				return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
			}
		}

		/// <summary>
		/// Get the assembly product
		/// </summary>
		public string AssemblyProduct {
			get {
				object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);

				if(attributes.Length == 0)
					return "";

				return ((AssemblyProductAttribute)attributes[0]).Product;
			}
		}

		/// <summary>
		/// Get the assembly company
		/// </summary>
		public string AssemblyCompany {
			get {
				object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);

				if(attributes.Length == 0)
					return "";

				return ((AssemblyCompanyAttribute)attributes[0]).Company;
			}
		}
	}
}